Reads all the tags stored in a TIFF file, along with the offsets for each tag.
public IList<RasterTagMetadata> ReadTagsWithOffsets(Stream stream,int pageNumber,out long[] offsets)
Public Overloads Function ReadTagsWithOffsets( _ByVal stream As Stream, _ByVal pageNumber As Integer, _ByRef offsets As Long() _) As IList(Of RasterTagMetadata)
- (nullable NSArray<LTRasterTagMetadata *> *)readTagsFromStream:(LTLeadStream *)streampageNumber:(NSInteger)pageNumberoffsets:(NSMutableArray<NSNumber *> *)offsetserror:(NSError **)error
public RasterCollection<RasterTagMetadata> readTagsWithOffsets(ILeadStream stream, int pageNumber, long[][] offsets) public:IList<RasterTagMetadata^>^ ReadTagsWithOffsets(Stream^ stream,int pageNumber,[Out] array<int64> offsets)
stream
A Stream containing the input image data.
pageNumber
1-based index of the page from which to read the tags.
offsets
An array that contains the offsets for each tag.
A collection of RasterTagMetadata containing all the tags found in the file. If the file does not contain any tags, an empty collection will be returned. If the file format does not support tags, an exception will be thrown.
To read a specific tag stored in a file, use ReadTag and to enumerate all the tag ids (but not the data) stored in a file use EnumTags.
This method will throw an exception if the file format does not support tags. To determine whether a file format supports tags, use TagsSupported. You can also automatically load all the tags stored in a file during a load operation by setting the CodecsLoadOptions.Tags property to true. The tags data will be stored in the resulting image RasterImage.Tags collection.
To load all the tags stored in a disk file, use ReadTags.
This example will load all the tags, with their offsets, from a file.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;using Leadtools.Svg;using LeadtoolsExamples.Common;public void ReadTagsWithOffsetsExample(){// Prompt the user for an image filestring imageFileName = PromptForFileName();// Initialize LEADTOOLSusing (RasterCodecs codecs = new RasterCodecs()){// Get the file formatRasterImageFormat format;using (CodecsImageInfo info = codecs.GetInformation(imageFileName, false)){format = info.Format;}// Load the tags, with their offsetsIList<RasterTagMetadata> tags = null;long[] offsets = null;if (RasterCodecs.TagsSupported(format))tags = codecs.ReadTagsWithOffsets(imageFileName, 1, out offsets);string txtFileName = Path.Combine(Path.GetDirectoryName(imageFileName),Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt");using (StreamWriter writer = File.CreateText(txtFileName)){// Write the tagsWriteTags(writer, "Tags", tags, offsets);}// Show the text file we createdSystem.Diagnostics.Process.Start(txtFileName);}}private static void WriteTags(StreamWriter writer, string name, IList<RasterTagMetadata> tags, long[] offsets){writer.WriteLine("{0}:", name);if (tags != null){int x = 0;foreach (RasterTagMetadata tag in tags){writer.WriteLine("Id: 0x{0}, offset: {1}", tag.Id.ToString("X"), offsets[x]);x++;}}else{writer.WriteLine("Not supported");}writer.WriteLine();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorImports Leadtools.DrawingImports Leadtools.SvgPrivate Shared Sub ReadTagsWithOffsetsExample()' Prompt the user for an image fileDim imageFileName As String = PromptForFileName()' Initialize LEADTOOLSUsing codecs As New RasterCodecs()' Get the file formatDim format As RasterImageFormatUsing info As CodecsImageInfo = codecs.GetInformation(imageFileName, False)format = info.FormatEnd Using' Load the tags, with their offsetsDim tags As IList(Of RasterTagMetadata) = NothingDim offsets As Long() = NothingIf RasterCodecs.TagsSupported(format) Thentags = codecs.ReadTagsWithOffsets(imageFileName, 1, offsets)End IfDim txtFileName As String = Path.Combine(Path.GetDirectoryName(imageFileName),Path.GetFileNameWithoutExtension(imageFileName) + "_metadata.txt")Using writer As StreamWriter = File.CreateText(txtFileName)' Write the tagsWriteTags(writer, "Tags", tags, offsets)End Using' Show the text file we createdSystem.Diagnostics.Process.Start(txtFileName)End UsingEnd SubPrivate Shared Sub WriteTags(ByVal writer As StreamWriter, ByVal name As String, ByVal tags As IList(Of RasterTagMetadata), ByVal offsets As Long())writer.WriteLine("{0}:", name)If Not IsNothing(tags) ThenDim x As Integer = 0For Each tag As RasterTagMetadata In tagswriter.WriteLine("Id: 0x{0}, offset: {1}", tag.Id.ToString("X"), offsets(x))x = x + 1NextElsewriter.WriteLine("Not supported")End Ifwriter.WriteLine()End Sub
ReadTag(String,Int32,Int32) Method
Implementing TIFF Comments and Tags
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
